import {CITY_DATA} from "@/config/properties";

export const TBFmt = {
    addrFmt({city, province, area}) {
        const fn = (num) => ({value}) => +value === +num;
        let p = CITY_DATA.find(fn(province)) as any,
            c = p?.children.find(fn(city)),
            a = c?.children.find(fn(area));
        return [p,c,a].filter(Boolean).map(({label})=>label).join("/")
    },addrFmtCode({cityCode, provinceCode, areaCode}) {
        const fn = (num) => ({value}) => +value === +num;
        let p = CITY_DATA.find(fn(provinceCode)) as any,
            c = p?.children.find(fn(cityCode)),
            a = c?.children.find(fn(areaCode));
        return [p,c,a].filter(Boolean).map(({label})=>label).join("/")
    }
}